<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
    <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
    <!--<script src="http://{$Think.config.google_map_url}" async="async"></script>-->
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<style>
    .layui-upload-img{
        width: 100px;!important;
    }
    .addclassify{
        display: inline-block;
        width: 40px;
        height: 40px;
        border: 1px solid #666;
        line-height: 40px;
        border-radius: 40px;
        text-align: center;
        cursor: pointer;
    }
</style>
<style>
    .list-group-item{
        margin: 5px 30px 5px 0;
        color: #212529;
        display: inline-block;
    }
    .list-group-item>i{
        color:red;
    }
</style>
<body>
<div style="margin-top: 20px;">
</div>

<form class="layui-form" id="admin">

    <div class="layui-tab layui-tab-card" style="box-shadow:none">
        <ul class="layui-tab-title">
            <li class="layui-this">基础信息</li>
            <li>视频相册</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">

                {notempty name="$goods"}
                <input type="hidden" name="goods_id" value="{$goods.goods_id}">
                {/notempty}
                <div class="layui-form-item">
                    <label class="layui-form-label">商品类型</label>
                    <div class="layui-input-inline" style="width: 450px">

                        <input type="radio"  lay-filter="protype" name="protype" value="0"  {if isset($goods.standard_pro) && $goods.standard_pro!=1}checked=""{/if} title="自营商品" >
                        <input type="radio"  lay-filter="protype" name="protype" value="1"  {if $goods.standard_pro==1}checked=""{/if} title="三方商品" >
                        <input type="hidden" name="standard_pro" value="{$goods.standard_pro}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">拼团商品</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <input type="radio" name="is_group" value="1" {if $goods.is_group==1}checked=""{/if} title="是" >
                        <input type="radio" name="is_group" value="0" {if $goods.is_group==0}checked=""{/if} title="否" >
                    </div>
                </div>
                <div class="layui-form-item" id="pro_source" {if empty($goods.standard_pro)}style="display:none"{/if}>
                    <label class="layui-form-label">商品来源</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <input type="radio"  lay-filter="channel_source" name="channel_source" value="fareharbor" title="fareharbor" {if $goods.channel_source=='fareharbor'}checked="checked"{/if}>
                        <input type="radio"  lay-filter="channel_source" name="channel_source" value="hotel" title="hotel" {if $goods.channel_source=='hotel'}checked="checked"{/if}>
                    </div>
                </div>
                <div class="layui-form-item" id="fareharbor_bloack" {if $goods.channel_source!='fareharbor'}style="display:none"{/if}>
                    <label class="layui-form-label">farehabor:</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select id="company" lay-filter="company" name="" lay-verify="" lay-search>
                            <option value="">请选择合作商</option>
                            {volist name="companyList" id="vo"}
                            <option value="{$vo.shortname}" {if !empty($item) && $vo.shortname==$item.company}selected='selected'{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                        <input type="hidden" name="company" value="{if isset($item['company'])}{$item['company']}{/if}">
                    </div>
                    <div class="layui-input-inline" style="width: 400px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select id="items" lay-filter="items" name="" lay-verify="" lay-search>
                            <option value="">请选择商品</option>
                            {volist name="itemList" id="vo"}
                            <option value="{$vo.fare_goods_id}" data-name="{$vo.company}" {if $vo.fare_goods_id==$goods.source_id}selected='selected'{/if}>{$vo.item_name}</option>
                            {/volist}
                        </select>
                        <input type="hidden" name="source_id" value="{$goods.source_id}">
                    </div>
                    <div class="layui-input-inline" id="fareharbor_location" style="color:red;">
                    </div>
                </div>
                <div class="layui-form-item" id="hotel_block" {if $goods.channel_source!='hotel'}style="display:none"{/if}>
                    <label class="layui-form-label">hotel:</label>
                    <div class="layui-input-inline" style="width: 400px">
                        <select id="hotel_id" lay-filter="hotel_id" name="" lay-verify="" lay-search>
                            <option value="">请选择酒店</option>
                            {volist name="hotelList" id="vo"}
                            <option value="{$vo.hotel_id}" data-name="{$vo.name}" {if $vo.hotel_id==$goods.source_id}selected='selected'{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                        <input type="hidden" name="source_id" value="{$goods.source_id}">
                    </div>
                    <div class="layui-input-inline" id="hotel_location" style="color:red;">
                    </div>
                </div>
                <div class="layui-form-item " id="shangpin">
                    <label class="layui-form-label">商品名称</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="goods_name"  value='{notempty name="$goods"}{$goods.goods_name}{/notempty}' placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>
                <div class="layui-form-item " id="">
                    <label class="layui-form-label">英文名称</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="goods_englishname"  value='{notempty name="$goods"}{$goods.goods_englishname}{/notempty}' placeholder="请输入商品名称" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">产品Code</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="goods_tcode"  value='{notempty name="$goods"}{$goods.goods_tcode}{/notempty}' placeholder="请输入行程编码" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">虚拟销量</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input value="{$goods.invented_sold|default=0}" placeholder="请输入整数" name="invented_sold" autocomplete="off" class="layui-input"  type="text" lay-verify="number">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">真实销量</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input value="{$goods.goodssales|default=0}" placeholder="请输入整数" readonly autocomplete="off" class="layui-input"  type="text" lay-verify="number">
                    </div>
                </div>

                <div class="layui-form-item ">
                    <label class="layui-form-label">主要城市</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select id="select_city" lay-filter="addtrips_city" name="city_id" lay-verify="required" lay-search>
                            <option value="">请选择主要城市</option>
                            {volist name="city" id="vo"}
                            <option value="{$vo.id}"{notempty name='$goods'}{if $goods.city_id==$vo.id} selected{/if}{/notempty}>{$vo.name}({$vo.eng_name})</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item ">
                    <label class="layui-form-label">附属城市</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select id="select_belong_city" lay-filter="addtrips_city" lay-verify="" lay-search>
                            <option value="">请选择附属城市</option>
                            <option value="999999">全部</option>
                            {volist name="city" id="vo"}
                            <option value="{$vo.id}">{$vo.name}({$vo.eng_name})</option>
                            {/volist}
                        </select>
                    </div>
                    <span id="addtrips_city" data-name="" data-id="0" class="layui-btn layui-btn-danger layui-btn-sm" style="margin-top: 4px">添加</span>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">已选城市</label>
                    <div class="layui-input-inline" style="width: 500px" id="tripnames_city">
                        <?php if(!empty($belongCityList)){ foreach($belongCityList as $v){?>
                        <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_city" data-id="{$v.id}" style="margin: 5px 10px">{$v.name}<i class="layui-icon"></i></span>
                        <?php }}elseif($belongcityid==999999){ ?>
                        <!-- 注释全部城市选项 -->
                        <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_city" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>
                        <?php } ?>
                    </div>
                </div>
                <input type="hidden" id="tripids_city" name="belong_city" value="{$belongcityid}" />

                <div class="layui-form-item ">
                    <label class="layui-form-label">商城分类</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select  lay-filter="classify"   name="classify_id"  lay-verify="required" lay-search>
                            {volist name="classify" id="vo"}
                            <option value="{$vo.classify_id}" {if $goods.classify_id==$vo.classify_id} selected{/if}>{$vo.classify_name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

        {empty name="$exist_pro"}
                <div class="layui-form-item ">
                    <label class="layui-form-label">订单分类</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select name="orderType" lay-filter="orderType" lay-verify="required" lay-search>
                            <option value>请选择</option>
                            {volist name="orderType" id="vo"}
                            <option value="{$vo.type}" {if $goods.orderType==$vo.type} selected{/if}>{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
        {/empty}

                <input type="hidden"  id="classify" value="{notempty name='$goods'}{$goods.classify_id}{else}{notempty name="$classify[0]['classify_id']"}{$classify[0]['classify_id']}{/notempty}{/notempty}">


                <div class="layui-form-item " >
                    <label class="layui-form-label">标签</label>
                    <div class="layui-input-inline" style="width: 400px">
                        <select  id="trip"  lay-filter="addtrips"   lay-verify="required" lay-search>
                            {volist name="tag" id="vo"}
                            <option value="{$vo.tag_id}">{$vo.tag_name}</option>
                            {/volist}
                        </select>
                    </div>
                    <span id="addtrips" data-name="{notempty name='$tag[0]["tag_id"]'}{$tag[0]["tag_name"]}{/notempty}" data-id="{notempty name='$tag[0]["tag_id"]'}{$tag[0]["tag_id"]}{/notempty}" class="layui-btn layui-btn-danger layui-btn-sm" style="margin-top: 4px">添加</span>
                </div>



                <div class="layui-form-item">
                    <label class="layui-form-label">已选标签</label>
                    <div class="layui-input-inline" style="width: 500px" id="tripnames">
                        {volist name="tagdata" id="vo"}
                        <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="{$vo['tag_id']}" style="margin: 5px 10px">{$vo['tag_name']}<i class="layui-icon"></i></span>
                        {/volist}
                    </div>
                </div>

                <input name="tag_id" id="tripids" value="{notempty name="$goods"}{$goods.tag_id}{/notempty}"   type="hidden">



                <div class="layui-form-item ">
                    <label class="layui-form-label">商品标签</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select name="goodstag_id" lay-search>
                            <option value="0">暂不配置</option>
                            {volist name="goodstags" id="vo"}
                            <option value="{$vo.tag_id}" {if $goods.goodstag_id==$vo.tag_id} selected{/if}>{$vo.tag_name}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">关联</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <input type="radio"  lay-filter="poitype" name="relation_type" value="0" {if $goods.relation_type==0}checked=""{/if} {empty name="$goods"}checked{/empty} title="不关联" >
                        <input type="radio"  lay-filter="poitype" name="relation_type" value="1" {if $goods.relation_type==1}checked=""{/if}  title="行程" >
                        <input type="radio"  lay-filter="poitype" name="relation_type" value="2" {if $goods.relation_type==2}checked=""{/if} title="POI" >
                    </div>
                </div>

                <input  id="relation_type" value="{notempty name="$goods"}{$goods.relation_type}{else}0{/notempty}"  type="hidden">

                <div class="layui-form-item " id="show_pro">
                    <label class="layui-form-label">关联项目</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <!--<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">-->
                        <select id="select_project" lay-filter="addtrips_project" lay-verify="" lay-search>
                            <option value="">请选择</option>
                            {volist name="relation" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                            {/volist}
                        </select>
                    </div>
                    <span id="addtrips_project" data-name="" data-id="0" class="layui-btn layui-btn-danger layui-btn-sm" style="margin-top: 4px">添加</span>
                    <span id="addcontent_project" data-name="" data-id="0" class="layui-btn layui-btn-warning layui-btn-sm" style="margin-top: 4px">简介</span>
                </div>
                <div class="layui-form-item" id="show_selected_pro">
                    <label class="layui-form-label">已选项目</label>
                    <div class="layui-input-inline" style="width: 500px" id="tripnames_project">
                        <?php if(!empty($projectList)){ foreach($projectList as $v){?>
                        <span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_project" data-id="{$v.id}" style="margin: 5px 10px">{$v.name}<i class="layui-icon"></i></span>
                        <?php }} ?>
                    </div>
                </div>
                <input type="hidden" id="tripids_project" name="goods_location" value="{$goodslocation}" />

                <div class="layui-form-item " id="" >
                    <label class="layui-form-label">选择状态</label>
                    <div class="layui-input-inline">
                        <select name="goods_status"  lay-verify="required">
                            <option  value="2" {if $goods.goods_status==2} selected{/if}>未售卖</option>
                            <option  value="1" {if $goods.goods_status==1} selected{/if}>售卖中</option>
                            <option  value="3" {if $goods.goods_status==3} selected{/if}>已售罄</option>
                        </select>
                    </div>
                </div>


                <div class="layui-form-item">
                    <label class="layui-form-label">是否可退</label>
                    <div class="layui-input-inline">
                        <select name="merchantCancellable" lay-verify="required">
                            <option value="1" {if $goods.merchantCancellable==1} selected{/if}>可退</option>
                            <option value="0" {if $goods.merchantCancellable==0} selected{/if}>不可退</option>
                        </select>
                    </div>
                </div>

        {empty name="$exist_pro"}
                <div class="layui-form-item ">
                    <label class="layui-form-label">二次确认</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select    name="need_confirm"  lay-verify="required" >
                            <option  value="" >未设置</option>
                            <option  value="1" {if $goods.need_confirm==1} selected{/if}>是</option>
                            <option  value="2" {if $goods.need_confirm==2} selected{/if}>否</option>
                        </select>
                    </div>
                </div>
        {/empty}
                {empty name="$exist_pro"}
                <div class="layui-form-item">
                    <label class="layui-form-label">上架时间</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <div class="layui-col-xs5">
                            <input name="starttime" lay-key="1" value="{notempty name="$goods"}{$goods.starttime|date="Y-m-d",###}{/notempty}" id="start_goodstime" lay-verify="required" placeholder="请输入开始时间" autocomplete="off" class="layui-input" type="text">
                        </div>
                        <div class="layui-col-xs2" style="text-align: center; line-height: 38px">~</div>
                        <div  class=" layui-col-xs5">
                            <input name="endtime" lay-key="2" value="{notempty name="$goods"}{$goods.endtime|date="Y-m-d",###}{/notempty}" id="end_goodstime" lay-verify="required" placeholder="请输入结束时间" autocomplete="off" class="layui-input layui-col-xs5" type="text">
                        </div>
                    </div>
                </div>
                {/empty}

                <!--<div class="layui-form-item " >-->
                <!--<label class="layui-form-label">商品来源</label>-->
                <!--<div class="layui-input-inline" style="width: 450px">-->
                <!--&lt;!&ndash;<input name="xp"  id="xp" value="" placeholder="请输入" autocomplete="off" list="list" class="layui-input"  type="text">&ndash;&gt;-->
                <!--<select  lay-filter="" id="team_id"  name="team_id"  lay-verify="required" lay-search>-->
                <!--<option value="999999"  {if $goods.team_id==999999} selected{/if}>自营</option>-->
                <!--{volist name="team" id="vo"}-->
                <!--<option value="{$vo.id}"  {if $goods.team_id==$vo.id} selected{/if}>{$vo.name}</option>-->
                <!--{/volist}-->
                <!--<option value="1000000" {if $goods.team_id==1000000} selected{/if}>其他</option>-->
                <!--</select>-->
                <!--</div>-->
                <!--</div>-->


                {empty name="$exist_pro"}
                <div class="layui-form-item " >
                    <label class="layui-form-label">供应商</label>
                    <div class="layui-input-inline" style="width: 450px">
                        <select  lay-filter="" id="supplier_id"  name="supplier_id"  lay-verify="required" lay-search>
                            <option value="" >供应商</option>
                            <option value="999999"  {if $goods.supplier_id==999999} selected{/if}>自营</option>
                            {volist name="supplier" id="vo"}
                            <option value="{$vo.id}"  {if $goods.supplier_id==$vo.id} selected{/if}>{$vo.name}</option>
                            {/volist}
                            <option value="1000000" {if $goods.supplier_id==1000000} selected{/if}>其他</option>
                        </select>
                    </div>
                </div>
                {/empty}

                <div class="layui-form-item " >
                    <label class="layui-form-label">官网</label>
                    <div class="layui-input-inline" style="width: 500px">
                        <input name="supplier_web"  value='{notempty name="$goods.supplier_web"}{$goods.supplier_web}{/notempty}' placeholder="请输入采购官网" autocomplete="off" class="layui-input"  type="text">
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">内部备注</label>
                    <div class="layui-input-block" style="max-width:500px;">
                        <textarea placeholder="请输入内容" class="layui-textarea"  name="internal_remark">{notempty name='$goods.internal_remark'}{$goods.internal_remark}{/notempty}</textarea>
                    </div>
                </div>


        {empty name="$exist_pro"}
        <div id="tob_item" {if $goods.orderType=='Vehicle'}style="display:none;"{/if}>
            <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
                <legend class="layui-inline">toB分类</legend>
                <p class="layui-inline" style="margin-left: 20px;color:palevioletred">【已选详细分类】支持拖拽排序！优先使用靠前的分类进行显示</p>
            </fieldset>
            <!--顶级分类-->
            <!--<div class="layui-form-item" id="topCategory">-->
                <!--<label class="layui-form-label">顶级分类</label>-->
                <!--<div class="layui-input-inline" style="width: 400px">-->
                    <!--<select name="topCate" id="topCate" lay-filter="topCate" lay-search>-->
                        <!--<option value="">请选择顶级分类</option>-->
                        <!--{notempty name="$topCate"}-->
                        <!--{volist name="topCate" id="vo"}-->
                        <!--<option value="{$vo.id}" {notempty name="$standard.topCate"}{if $standard.topCate==$vo.id}selected{/if}{/notempty}>{$vo.name}</option>-->
                        <!--{/volist}-->
                        <!--{/notempty}-->
                    <!--</select>-->
                <!--</div>-->
            <!--</div>-->
            <!--详细分类[多选]-->
            <div class="layui-form-item" id="firstCategory">
                <label class="layui-form-label">详细分类<br>[多选]</label>
                <div class="layui-input-inline" style="width: 400px">
                    <select name="categorytagid" id="categorytags" lay-filter="addCategoryTags" lay-search>
                        <option value="">请选择详细分类</option>
                        <!--初始化-->
                        {notempty name="$tags"}
                        {volist name="tags" id="cate"}
                        <option value="{$cate.tag_id}">{$cate.tag_name}</option>
                        {/volist}
                        {/notmepty}
                    </select>
                </div>
            </div>
            <!--已选详细分类-->
            <div class="layui-form-item" >
                <label class="layui-form-label">已选<br>详细分类</label>
                <div class="layui-input-inline" style="width: 400px">
                    <blockquote class="layui-elem-quote elem-quote-div">
                        <div id="shared-lists" class="shared-lists">
                            <div class="boxcont" id="boxcont">
                                <div id="sortTags" class="example2 schedule_div" style="padding:15px;">
                                    {notempty name="$tagsData"}
                                    {volist name="tagsData" id="tag"}
                                    <span class="list-group-item list-group-{$tag.tagid}" value="{$tag.tagid}" id="{$tag.tagid}">{$tag.tag_name}<i class="layui-icon">&#x1006;</i></span>
                                    {/volist}
                                    {/notempty}
                                </div>
                            </div>
                        </div>
                    </blockquote>
                </div>
            </div>
            <input type="hidden" name="subCates" value="{notempty name='$tagsData'}{$tagsData|array_column=###,'tagid'|implode=',',###}{/notempty}">
            <div class="layui-form-item">
                <label class="layui-form-label">上架ToB</label>
                <div class="layui-input-inline" style="width: 450px">
                    <input type="radio" name="show_toB" value="1" {if $standard.show_toB=='1'}checked=""{/if} title="是" >
                    <input type="radio" name="show_toB" value="0" {if $standard.show_toB=='0'}checked=""{/if} title="否" >
                </div>
            </div>
            <fieldset class="layui-elem-field layui-field-title" style="margin-bottom: 30px;">

            </fieldset>
        </div>
        {/empty}
                <div class="layui-form-item layui-form-text" style="position: relative ;z-index: 98">
                    <label class="layui-form-label">简介</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="jieshao" name="goods_introduce">{notempty name="$goods"}{$goods.goods_introduce}{/notempty}</textarea>
                    </div>
                </div>



                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">用时参考</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="yongshi" name="goods_usetime">{notempty name="$goods"}{$goods.goods_usetime}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">费用包含</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="baohan" name="price_include">{notempty name="$goods"}{$goods.price_include}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">费用不含</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="buhan" name="price_noinclude">{notempty name="$goods"}{$goods.price_noinclude}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">注意事项</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="zhuyi" name="goods_careful">{notempty name="$goods"}{$goods.goods_careful}{/notempty}</textarea>
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">退改规则</label>
                    <div class="layui-input-block" style="max-width:800px;">
                        <textarea placeholder="请输入内容"  class="layui-textarea" id="tuigai" name="goods_retreating">{notempty name="$goods"}{$goods.goods_retreating}{/notempty}</textarea>
                    </div>
                </div>

                <!--<div class="layui-form-item layui-form-text">-->
                <!--<label class="layui-form-label">英文介绍</label>-->
                <!--<div class="layui-input-block" style="max-width:500px;">-->
                <!--<textarea placeholder="请输入内容"  class="layui-textarea" id="jieshao2" name="goods_enintroduce"></textarea>-->
                <!--</div>-->
                <!--</div>-->

            </div>
            <div class="layui-tab-item">
                <div class="layui-form-item" style="margin:0 110px ">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="upload1">图片上传（格式：jpg,png,gif,jpeg）                                                                                      </button>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            预览图：
                            <div class="layui-upload-list" id="seeupload1">
                                {volist name="$goodsimage" id="vo"}
                                {notempty name='$vo'}
                                <span class="uploadimgbox"><img class="layui-upload-img" src="{$vo}" width="100px"><i class="layui-icon">&#x1006;</i></span>
                                {/notempty}
                                {/volist}
                            </div>
                        </blockquote>
                    </div>
                    <input id="upload-thumb1" type="hidden" name="goods_image" value="{notempty name='$goods'}{$goods.goods_image}{/notempty}">
                </div>
                <div class="layui-form-item" style="margin:0 110px ">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn" id="test5"><i class="layui-icon"></i>上传视频</button>
                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                            视频预览：
                            <div class="layui-upload-list" id="seevideo">
                                {notempty name="$goods.goods_video"}
                                <video controls style="width: 400px">
                                    <source  src="{$goods.goods_video}">
                                </video>
                                {/notempty}
                            </div>
                        </blockquote>
                    </div>

                    <input id="upload-video" type="hidden" name="goods_video" value="{$goods.goods_video}">
                </div>

            </div>
        </div>


    </div>

    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label">选择文件</label>-->
    <!--<div class="layui-input-inline">-->
    <!--<button type="button" class="layui-btn" id="uploadfile"><i class="layui-icon"></i><span id="uploadname">{if empty($menu['fileid'])||$menu['fileid']<1}上传文件{else}更改文件{/if}</span>（格式：PDF或者WORD）</button>-->
    <!--</div>-->
    <!--<input name="fileid" id="fileid" value="{notempty name='$menu'}{$menu.fileid}{/notempty}" placeholder="请输入" autocomplete="off" class="layui-input" type="hidden">-->
    <!--</div>-->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="admin">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script src="__PUBLIC__/drag/Sortable.js"></script>

<script>
    var message;
    layui.config({
        base: '__JS__/',
        version: '1.0.1'
    }).use(['app', 'message'], function() {
        var app = layui.app,
            $ = layui.jquery,
            layer = layui.layer;
        //将message设置为全局以便子页面调用
        message = layui.message;
        //主入口
        app.set({
            type: 'iframe'
        }).init();
    });
    function clearFaregoods(){
        // $("input[name=company]").val('');
        // $("input[name=source_id]").val('');
        // $("input[name=goods_name]").val('');
        // $("input[name=goods_englishname]").val('');
        ue0.setContent('');
        zhuyi.setContent('');
    }

    //清除fareharbor的产品编码
    function clearFareProductCode()
    {
        $("input[name=goods_tcode]").val("");

    }
    //设置fareharbor的产品编码
    function setFareProductCode(company,itemId)
    {
        var productCode = "F_" + company.toUpperCase() + "_" + itemId;
        $("input[name=goods_tcode]").val(productCode);
    }
    //设置fareharbor的产品编码
    function setHotelProductCode(itemId)
    {
        var productCode = "H__" + itemId;
        $("input[name=goods_tcode]").val(productCode);
    }

    //设置fareharbor的产品编码
    function setFareProductLocation(location)
    {
        $("#fareharbor_location").html("地址："+location);
        $("#fareharbor_location").show();
    }
    function setHotelProductLocation(location)
    {
        $("#hotel_location").html("地址："+location);
        $("#hodel_location").show();
    }

    function clearFareProductLocation()
    {
        $("#fareharbor_location").html('');
        $("#fareharbor_location").hide('');
    }
    function getFaregoodsInfo(id)
    {
        $.post("/admin/faregoods/getFaregoosInfo",{id:id},function(data){
            if(data.code==200){
                $("input[name=goods_name]").val(data.data.item_name)
                $("input[name=goods_englishname]").val(data.data.item_name)
                ue0.setContent('');
                if (data.data.description_safe_html!==null && data.data.description_safe_html!=''){
                    ue0.setContent(data.data.description_safe_html);
                }
                zhuyi.setContent('');
                if (data.data.booking_notes!==null && data.data.booking_notes!=''){
                    zhuyi.setContent(data.data.booking_notes);
                }
                //赋值产品编码
                setFareProductCode(data.data.company,data.data.item_id)
                setFareProductLocation(data.data.location)
            }
        },"json")
    }
    function getHotelDetail(id)
    {
        $.post("/admin/hotel/getHotelSpuDetail",{hotel_id:id},function(data){
            if(data.code==200){
                $("input[name=goods_name]").val(data.data.name)
                $("input[name=goods_englishname]").val(data.data.en_name)
                ue0.setContent('');
                if (data.data.introduce!==null && data.data.introduce!=''){
                    ue0.setContent(data.data.introduce);
                }
//                zhuyi.setContent('');
//                if (data.data.booking_notes!==null && data.data.booking_notes!=''){
//                    zhuyi.setContent(data.data.booking_notes);
//                }
                //赋值产品编码
                setHotelProductCode(data.data.hotel_id);
                setHotelProductLocation(data.data.address)
            }
        },"json")
    }
</script>
<!-- 配置文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>

<script>
    layui.use(['layer', 'form','laydate','element'], function() {
        var $ = layui.jquery,
            laydate= layui.laydate
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
        laydate.render({
            elem: '#start_goodstime' //指定元素
            ,trigger:'click'
        });
        laydate1= layui.laydate;
        laydate1.render({
            elem: '#end_goodstime' //指定元素
            ,trigger:'click'
        });
    });



    //文件上传
    layui.use('upload', function(){
        var upload = layui.upload;
        //执行实例图片
        upload.render({
            elem: '#upload1'
            ,url: "{:url('common/upload')}"
            ,multiple: true
            ,accept:"images"
            ,size:"50000"
            ,done: function(res){
                //上传完毕回调
                layer.closeAll('loading');
                if(res.code == 2) {
                    $('#seeupload1').append('<span class="uploadimgbox"><img class="layui-upload-img" src="'+res.src+'"><i class="layui-icon">&#x1006;</i></span>');
                    $('#upload-thumb1').val($('#upload-thumb1').val()+","+res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error: function(){
                //请求异常回调
                //演示失败状态，并实现重传
                layer.closeAll('loading');
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function(){
                    uploadInst.upload();
                });
            }
            ,before:function(){
                layer.load(2);
            }
        });

        //执行实例视频
        upload.render({
            elem: '#test5'
            ,url: "{:url('common/upload')}"
            ,accept: 'video' //视频
            ,size:'65536'
            ,done: function(res){
                layer.closeAll('loading');
                if(res.code == 2) {
                    layer.msg("文件上传成功");
                    $("#seevideo").html('<video controls style="width: 400px">\n' +
                        '<source  src="'+res.src+'">\n' +
                        '</video>');
                    $("#upload-video").val(res.src);
                } else {
                    layer.msg(res.msg);
                }
            }
            ,error:function () {
                layer.closeAll('loading');
            }
            ,before:function () {
                layer.load(2);
            }
        });
    });


    $("#seeupload1").on("click",".layui-icon",function(){
        $(this).parent().remove();
        thumb("seeupload1",1);
    });

    function thumb(obj,n){
        var thumbs="";
        $("#"+obj).find("img").each(function(){
            var url=$(this).attr("src");
            thumbs+=","+url;
        });
        $("#upload-thumb"+n).val(thumbs);
    }

</script>




<script>
    //关联产品后 详情 退改规则 包含不含不可编辑
    var exist_pro = {if $exist_pro > 0}true{else}false{/if};
    var toolbars = [
        [
            'anchor', //锚点
            'undo', //撤销
            'redo', //重做
            'bold', //加粗
            'indent', //首行缩进
            'italic', //斜体
            'source', //源代码
            'pasteplain', //纯文本粘贴模式
            'removeformat', //清除格式
            'unlink', //取消链接
            'cleardoc', //清空文档
            'fontfamily', //字体
            'fontsize', //字号
        ],[
            'simpleupload', //单图上传
            'insertimage', //多图上传
            'link', //超链接
            'justifyleft', //居左对齐
            'justifyright', //居右对齐
            'justifycenter', //居中对齐
            'justifyjustify', //两端对齐
            'forecolor', //字体颜色
            'backcolor', //背景色
            'fullscreen', //全屏
            'attachment', //附件
            'imagecenter', //居中
        ]
    ];
    ueConfig = {
        readonly: exist_pro,
        toolbars:toolbars,
        initialFrameWidth: 800,

    };
    var ue0 = UE.getEditor('jieshao',ueConfig);
    // var jieshao2 = UE.getEditor('jieshao2');
    var yongshi = UE.getEditor('yongshi',{toolbars:toolbars});
    var baohan = UE.getEditor('baohan',ueConfig);
    var buhan = UE.getEditor('buhan',ueConfig);
    var zhuyi = UE.getEditor('zhuyi',ueConfig);
    var tuigai = UE.getEditor('tuigai',ueConfig);


    function muban(t){
        var op=""
        op+=" <option  value=''>请选择</option>"
        $.each(t,function (i,v) {
            op+="<option value='"+v.id+"'>"+v.name+"</option>"
        })
        return op;
    }

    function team(t){
        var op="";
        op+="  <option value=\"999999\">自营</option>";
        $.each(t,function (i,v) {
            op+="<option value='"+v.id+"'>"+v.name+"</option>"
        });
        op+="  <option value=\"1000000\">其他</option>";
        return op;
    }


    layui.use(['layer', 'form','laydate','layedit'], function() {
        // var laydate = layui.laydate;
        var layer = layui.layer,
            $ = layui.jquery,
            laydate= layui.laydate,
            form = layui.form;

        function changepoi(){
            var id=$("#relation_type").val();
            var city=$("#select_city").val();
            var goods_classify=$("#classify").val();
            
            $('#select_project option').remove();
            $("#tripnames_project").children().remove();
            $('input[name=goods_location]').val("");
            if(id==0){
                form.render('select');
                return false;
            }
            
            $.post("{:url('findpoi')}",
                {
                    'id':id,
                    'city':city,
                    'goods_classify':goods_classify,
                },
                function (date) {

                    var data =JSON.parse(date);
                    console.log(data);
                    $('#select_project option').remove();
                    $('#select_project').append(muban(data.poi));


                    $('#team_id option').remove();
                    $('#team_id').append(team(data.team));

                    form.render('select');
                })
        }

        $(window).on('load', function() {

            form.on('radio(poitype)', function(data){
                var val= $(this).val();
                $("#relation_type").val(val);

                changepoi()
            })


            $('#queding').click(function () {
                var id= $(this).attr("data-id");
                console.log(id)

            })

            //切换商品类型
            form.on('radio(protype)',function(data){
                clearFaregoods()
                $("input[name=standard_pro]").val(data.value)
                if(data.value==1){
                    $("#pro_source").show();
                    $("#fareharbor_bloack").show();
                    $("input[name=goods_tcode]").attr("readonly","readonly");
                    $("input[name=goods_tcode]").css("backgroundColor","#eee");
                    var company = $("#company").val();
                    var item_id = $("#items").val();
                    if(company!=='' && company!==undefined && item_id!=='' && item_id!==undefined){
                        setFareProductCode(company,item_id);
                    }
                }else{
                    clearFareProductCode();
                    $("#pro_source").hide();
                    $("#fareharbor_bloack").hide();
                    $("input[name=goods_tcode]").removeAttr("readonly");
                    $("input[name=goods_tcode]").css("backgroundColor","#fff");

                }
            })

            //company选择下拉添加事件
            form.on('select(company)', function(data){
                $("#items").val("");
                clearFareProductLocation();
                form.render('select');
                var name = data.value;
                var list = $("#items").parent().find("dd:not(:first)");
                list.hide();
                var items = $("#items option:not(:first)");
                $.each(items,function(i,v){
                    if($(v).attr("data-name")==name){
                        $(list[i]).show()
                    }
                })
                $("#items").get(0).selectedIndex=0;
                $("input[name=company]").val(name);
                $("input[name=source_id]").val("");
                clearFaregoods()
            });
            //item选择下拉添加事件
            form.on('select(items)', function(data){
                //更新商品信息
                var id = data.value;
                $("input[name=source_id]").val(id);
                getFaregoodsInfo(id);
            });
            form.on('select(hotel_id)', function(data){
                //更新商品信息
                var id = data.value;
                $("input[name=source_id]").val(id);
                getHotelDetail(id);
            });
            form.on('select(select_city)', function(data){
                var id=data.value;
                $("#city").val(id);
                changepoi()
            });

            form.on('select(classify)', function(data){
                var id=data.value;
                $("#classify").val(id);
                changepoi()
            });


            $("#addcontent_project").on("click",function () {
                var id = $("#select_project").val();
                if(id=="" || id==undefined || id==0){
                    layer.msg("请先选择关联项目");
                    return false;
                }
                var sid= $('input[name="relation_type"]:checked').val();
                // console.log($id)
                $.post("{:url('xiala')}",{'sid':sid,'id':id},function (date) {
                    var date=eval(date);
                    ue0.setContent('');
                    // jieshao2.setContent('');
                    yongshi.setContent('');
                    baohan.setContent('');
                    buhan.setContent('');
                    zhuyi.setContent('');
                    tuigai.setContent('');

                    if (date[0].hasOwnProperty('introduction') && date[0]['introduction']!==null){
                        ue0.setContent(date[0]['introduction']);
                    }
                    if (date[0].hasOwnProperty('price')  && date[0]['price']!==null){
                        baohan.setContent(date[0]['price']);
                    }
                    if (date[0].hasOwnProperty('priceno')  && date[0]['priceno']!==null){
                        buhan.setContent(date[0]['priceno']);
                    }
                    // if (date[0].hasOwnProperty('eng_introduce')  && date[0]['eng_introduce']!==null){
                    //     jieshao2.setContent(date[0]['eng_introduce']);//英文简介
                    // }
                    if (date[0].hasOwnProperty('introduce')  && date[0]['introduce']!==null){
                        ue0.setContent(date[0]['introduce']);
                    }

                    if (date[0].hasOwnProperty('careful')  && date[0]['careful']!==null){
                        zhuyi.setContent(date[0]['careful']);
                    }
                    if (date[0].hasOwnProperty('back')  && date[0]['back']!==null){
                        tuigai.setContent(date[0]['back']);

                    }


                });
            });



            //城市选择
            form.on('select(addtrips_city)', function (data) {
                var tripid = data.value;
                $("#addtrips_city").attr("data-id", tripid);
            });
            $("#addtrips_city").on("click", function () {
                var tripid = $("#addtrips_city").attr("data-id");
                var tripids = $("#tripids_city").val();
                var ids = tripids.split(",");

                if (tripid == 0 || tripid == '') {
                    layer.msg("请选择城市");
                    return false;
                }else if (tripid == 999999) {
                    tripids = 999999;
                    var tripspan = '<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_city" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                    $("#tripnames_city").html(tripspan);
                } else {
                    for (var i = 0; i < ids.length; i++) {
                        if (tripid == ids[i]) {
                            layer.msg("不能重复添加城市");
                            return false;
                        }else if(ids[i] == 999999){
                            layer.msg("您已选择全部城市");
                            return false;
                        }
                    }
                    var tripname = "";
                    $("#select_belong_city").find("option").each(function () {
                        if ($(this).val() == tripid) {
                            tripname = $(this).html();
                        }
                    });

                    var tripspan = '<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_city" data-id="' + tripid + '" style="margin: 5px 10px">' + tripname + '<i class="layui-icon"></i></span>';
                    if (!tripids) {
                        tripids += tripid;
                    } else {
                        tripids += ',' + tripid;
                    }
                    $("#tripnames_city").append(tripspan);
                }
                $("#tripids_city").val(tripids);
            });
            $(document).on("click", '.deltripspan_city', function () {
                var dataid = $(this).attr("data-id");
                var tripids = $("#tripids_city").val();
                var ids = tripids.split(",");
                var newid = "";
                for (var i = 0; i < ids.length; i++) {
                    if (ids[i] && dataid != ids[i]) {
                        if (!newid) {
                            newid += ids[i];
                        } else {
                            newid += "," + ids[i];
                        }
                    }
                }
                $("#tripids_city").val(newid);
                $(this).remove();
            });
            //项目选择
            form.on('select(addtrips_project)', function (data) {
                var tripid = data.value;
                $("#addtrips_project").attr("data-id", tripid);
            });


            form.on('select(orderType)', function (data) {
                var orderType = data.value;
                if(orderType=='Vehicle'){
                    $("#tob_item").hide();
                }else{
                    $("#tob_item").show();
                }
            });


            $("#addtrips_project").on("click", function () {
                var tripid = $("#addtrips_project").attr("data-id");
                var tripids = $("#tripids_project").val();
                var ids = tripids.split(",");
                if (tripid == 0 || tripid == '') {
                    layer.msg("请选择项目");
                    return false;
                }else if (tripid == 999999) {
                    tripids = 999999;
                    var tripspan = '<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_project" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                    $("#tripnames_project").html(tripspan);
                } else {
                    for (var i = 0; i < ids.length; i++) {
                        if (tripid == ids[i]) {
                            layer.msg("不能重复添加项目");
                            return false;
                        }else if(ids[i] == 999999){
                            layer.msg("您已选择全部项目");
                            return false;
                        }
                    }
                    var tripname = "";
                    $("#select_project").find("option").each(function () {
                        if ($(this).val() == tripid) {
                            tripname = $(this).html();
                        }
                    });

                    var tripspan = '<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan_project" data-id="' + tripid + '" style="margin: 5px 10px">' + tripname + '<i class="layui-icon"></i></span>';
                    if (!tripids) {
                        tripids += tripid;
                    } else {
                        tripids += ',' + tripid;
                    }
                    $("#tripnames_project").append(tripspan);
                }
                $("#tripids_project").val(tripids);
            });
            $(document).on("click", '.deltripspan_project', function () {
                var dataid = $(this).attr("data-id");
                var tripids = $("#tripids_project").val();
                var ids = tripids.split(",");
                var newid = "";
                for (var i = 0; i < ids.length; i++) {
                    if (ids[i] && dataid != ids[i]) {
                        if (!newid) {
                            newid += ids[i];
                        } else {
                            newid += "," + ids[i];
                        }
                    }
                }
                $("#tripids_project").val(newid);
                $(this).remove();
            });
            //商品范围选择下拉添加事件
            //商品范围选择下拉添加事件
            form.on('select(addtrips)', function(data){
                var tripid=data.value;
                $("#addtrips").attr("data-id",tripid);
            });

            $("#addtrips").on("click",function () {
                var tripid= $("#addtrips").attr("data-id");
                var tripids=$("#tripids").val();
                var ids=tripids.split(",");

                if (tripid==999999){
                    tripids=999999;
                    var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                    $("#tripnames").html(tripspan);
                }else{
                    for(var i=0 ; i < ids.length; i++){
                        if(tripid==ids[i]){
                            layer.msg("不能重复添加商品");
                            return false;
                        }
                        if(ids[i]==999999){
                            tripids=999999;
                            var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="999999" style="margin: 5px 10px">全部<i class="layui-icon"></i></span>';
                            $("#tripnames").html(tripspan);
                            $("#tripids").val(tripids);
                            return false;
                        }
                    }
                    var tripname="";
                    $("#trip").find("option").each(function () {
                        if($(this).val()==tripid){
                            tripname=$(this).html();
                        }
                    });

                    var tripspan='<span class="layui-btn layui-btn-sm layui-btn-normal deltripspan" data-id="'+tripid+'" style="margin: 5px 10px">'+tripname+'<i class="layui-icon"></i></span>';
                    if(!tripids){
                        tripids+=tripid;
                    }else{
                        tripids+=','+tripid;
                    }
                    $("#tripnames").append(tripspan);
                }
                $("#tripids").val(tripids);
            });

            $(document).on("click",'.deltripspan',function () {
                var dataid=$(this).attr("data-id");
                var tripids=$("#tripids").val();
                var ids=tripids.split(",");
                var newid="";
                for(var i=0 ; i < ids.length; i++){
                    if(ids[i]&&dataid!=ids[i]){
                        if(!newid){
                            newid+=ids[i];
                        }else{
                            newid+=","+ids[i];
                        }
                    }
                }
                $("#tripids").val(newid);
                $(this).remove();
            });
            //切换fareharbor 和 hotel
            form.on('radio(channel_source)',function(data){
                if(data.value=='hotel'){
                    $("#fareharbor_bloack").hide();
                    $("#hotel_block").show();
                }else if(data.value=='fareharbor'){
                    $("#fareharbor_bloack").show();
                    $("#hotel_block").hide();
                }
            })
            form.on('submit(admin)', function(data) {
                //判断是否添加poi
                var id=$("#relation_type").val();
                var location=$("input[name=goods_location]").val();
                if(id==2 && (location=="" || location==0 || location==undefined)){
                    layer.msg("请先添加关联项目");
                    return false;
                }
                //判断是否添加fareharbor
                var standard_pro = $("input[name=standard_pro]").val();
                var channel_source = $("input[name=channel_source]:checked").val();
                var company = $("input[name=company]").val();
                var source_id = $("input[name=source_id]").val();

                if(standard_pro==1 && channel_source=='fareharbor'){
                    if(company=='' || company==null){
                        layer.msg("请先选择合作商");
                        return false;
                    }
                    if(source_id=='' || source_id==null){
                        layer.msg("请先选择关联商品");
                        return false;
                    }
                }else if(standard_pro==1 && channel_source=='hotel'){
                    if(source_id=='' || source_id==null){
                        layer.msg("请先选择关联酒店");
                        return false;
                    }
                }
                var load = layer.load(2);
                $.ajax({
                    url:"{:url('admin/goods/addgoods')}",
                    data:$('#admin').serialize(),
                    type:'post',
                    async: false,
                    success:function(res) {
                        layer.msg(res.msg);
                        layer.close(load);
                        if(res.code == 1) {
                            setTimeout(function(){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            },1500)
                        }
                    }
                })
                return false;
            });

            $('.example2').each(function () {
                new Sortable( document.getElementById("sortTags"), {
                    group: 'shared',
                    animation: 150,
                    scroll:true,
                    forceFallback: true,
                    onEnd:function (evt) {
                        var schedule_id = evt.to.id;
                        var one1=evt.item.id
                        var str = '';
                        $("#"+schedule_id).find(".list-group-item").each(function(){
                            str += ","+$(this).attr("id");
                        });
                        console.log(evt.to.id,evt.item.id,str)
                        return false;
                    }
                });
            });

            $(document).on('click','.list-group-item i',function () {
                var tagId = $(this).parent().attr('value');
                var subCates = $("input[name=subCates]").val();
                subCates = subCates.split(',');
                subCates.splice($.inArray(tagId,subCates),1);
                subCates = subCates.length > 0 ? subCates.join(',') : '';
                $("input[name=subCates]").val(subCates);
                $(this).parent().remove();
            })
            //设置标签
//            form.on('select(topCate)',function(data){
//                var value = data.value;
//                var subCates = [];
//                $.each(topCates,function (i,v) {
//                    if(v.id==value){
//                        subCates = v.subCates;return false;
//                    }
//                })
//                console.log(subCates);
//                var str = '';
//                $.each(subCates,function(i,v){
//                    str += "<option value='"+v.tag_id+"'>"+v.tag_name+"</option>";
//                });
//                $("#categorytags option:not(:first-child)").remove();
//                $("#categorytags").append(str);
//                //清空分类数据
//                $("input[name=subCates]").val("");
//                $("#sortTags").children().remove();
//                form.render('select');
//            });
            //首页分类标签选择
            form.on('select(addCategoryTags)', function(data){
                //添加内容到拖拽框
                var tagId = data.value;
                var tagName = $(this).text();
                if(tagId=="" || tagId==undefined){return false;}
                //判断是否已存在
                var isExistId = false;
                $.each($("#sortTags .list-group-item"),function (i,v) {
                    if($(v).attr("value")==tagId){
                        isExistId = true;layer.msg('请勿重复选择');return false;
                    }
                })
                if(isExistId){return false;}
                var subCates = $("input[name=subCates]").val();
                subCates = (subCates=="" || subCates==undefined) ? [] : subCates.split(',');
                subCates.push(tagId);
                $("input[name=subCates]").val(subCates.join(","));
                $("#sortTags").append('<span class="list-group-item list-group-'+tagId+'" value="'+tagId+'" id="'+tagId+'">'+tagName+'<i class="layui-icon">&#x1006;</i></span>');
            });

        });
    });
</script>
</body>
</html>
